<?php $this->addScript('ratingCss-'.$options['rating'],'<link rel="stylesheet" type="text/css" href="'.$html->url('/cms/css/star_rating.css?star='.$options['rating']).'" />'); ?>
<?php
	$field = $fieldId;
?>
<ul class="star-rating" id ="rating-<?php echo $field?>">
<li class="star" style=""></li>	
<?php	
	for($i=1;$i<$options['rating']+1;$i++)
	{?>
		<li class="ratingControls">
			<a class="star-<?php echo $i?>" title="<?php echo $i?> <?php echo __("star out of")?> <?php echo $options['rating']?>" href="#"><?php echo $i?></a>
		</li>
	<?php }?>
</ul>
<div id="rated_value_<?php echo $field?>"></div>
<div id="rated_revert_<?php echo $field?>" style="display:none"><a href="#"><?php echo __('ChangeRating')?></a></div>
<script type="text/javascript">
$(document).ready(function(){
	if($('#<?php echo $fieldId?>').val()!='')
	{
		$('#rating-<?php echo $field?> > li:first').addClass('current-rating');
		$('#rating-<?php echo $field?>').addClass('star-rating-disabled');
		$('#rating-<?php echo $field?>').attr('style','display:block');
		$('#rating-<?php echo $field?> > li:first').attr('style','width:'+$('#<?php echo $fieldId?>').val()*25+'px');
		$('#rated_value_<?php echo $field?>').text('<?php echo __("You Rated:",false)?>'+$('#<?php echo $fieldId?>').val()+'<?php echo __("star out of"); echo $options['rating']?>');
		$('#rated_revert_<?php echo $field?>').attr('style','');
		$('ul#rating-<?php echo $field?> > li > a').unbind('mouseover');
	}
	bindFor<?php echo $field?>();
	$('ul#rating-<?php echo $field?> > li > a').click(function(event)
{
	var rating  = $(this).text();
	event.preventDefault();	
	$('#<?php echo $fieldId?>').val($(this).text());
	$('#rating-<?php echo $field?>').addClass('star-rating-disabled');
	$('#rating-<?php echo $field?>').attr('style','display:block');
	$('ul#rating-<?php echo $field?> >li.ratingControls > a').removeAttr('href');
	$('#rating-<?php echo $field?> > li:first').addClass('current-rating');
	<?php
			if(isset($options['onchange']) && $options['onchange']!='')
				echo $options['onchange'].';';
	?>
	$('#rating-<?php echo $field?> > li:first').attr('style','width:'+rating*25+'px');
	$('#rated_value_<?php echo $field?>').text('<?php echo __("You Rated:")?>'+$(this).text()+' <?php echo __("star out of")?> <?php echo $options['rating']?>');
	<?php if(!isset($options['rate_revert']) || $options['rate_revert']==true)
	{?>
		$('#rated_revert_<?php echo $field?>').attr('style','');
	<?php }?>
	$('ul#rating-<?php echo $field?> > li > a').unbind('mouseover');
});

<?php if(!isset($options['rate_revert']) || $options['rate_revert']==true)
	{?>
	$('#rated_revert_<?php echo $field?>').click(function(event){
		event.preventDefault();
		$('#rating-<?php echo $field?>').removeClass('star-rating-disabled');
		$('#rating-<?php echo $field?> > li:first').removeClass('current-rating');
		$('#rating-<?php echo $field?> > li:first').attr('style','');
		$('#rated_value_<?php echo $field?>').text('');
		$('ul#rating-<?php echo $field?> >li.ratingControls > a').attr('href','#');
		$('#<?php echo $fieldId?>').val('');
		bindFor<?php echo $field?>();
	})
<?php } ?>
function bindFor<?php echo $field?>()
{
	$('ul#rating-<?php echo $field?> > li > a').bind('mouseover',function(event)
	{
		$('#rating-<?php echo $field?> > li:first').removeClass('current-rating');
		$('#rating-<?php echo $field?> > li:first').attr('style','');
		$('#rated_value_<?php echo $field?>').text($(this).attr('title'));
	});
}
})
</script>